package com.member.mp;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import com.member.system.cache.CommonCache;
import com.member.system.domain.SysConfig;
import com.member.system.service.ISysConfigService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author thomas
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.member"})
@EnableAsync
public class MpApplication {


    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(MpApplication.class, args);
        List<Term> a = HanLP.segment("前端接口服务启动成功");
        SysConfig sysConfig = new SysConfig();

        ISysConfigService sysConfigService = run.getBean(ISysConfigService.class);
        List<SysConfig> configs = sysConfigService.selectConfigList(sysConfig);
        CommonCache.reloadConfigCache(configs);
        System.out.println("(♥◠‿◠)ﾉﾞ  前端接口服务启动成功   ლ(´ڡ`ლ)ﾞ");
    }
}
